package view;

import java.awt.Dimension;
import java.awt.Rectangle;

import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.text.DefaultCaret;
import javax.swing.text.Document;

import model.FieldStats;
import model.Simulator;


/**
 * The class TextView extends AbstractView
 * @author Arjan Frans, Alwin Rombout, Jelte Verbree, Brendan Kanters
 * @version 1.0
 */
public class TextView extends AbstractView {
	private JTextArea textArea;
	private JScrollPane pScroll;
	
	/**
	 * make a new TextView
	 * @param simulator
	 */
	public TextView(Simulator simulator)
	{
		super(simulator);
		textArea = new JTextArea(20,40);
		JScrollPane scrollPane = new JScrollPane(textArea);
		this.add(scrollPane);
	}
	
	/**
	 * overrides the updateView method
	 */
	@Override
	public void updateView()
	{
		String stats = simulator.getStats().getPopulationDetails(simulator.getField());
		String step = simulator.getStep();
		
		textArea.append("Step: " + step + "; " + stats + "\n");
		textArea.setCaretPosition(textArea.getText().length() );
	}
	
	/**
	 * overrides the cleaView method
	 */
	@Override
	public void clearView()
	{
		textArea.setText("");
	}
	
}
